package threading;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2023-07-08
 * Time: 15:08
 */
public class ThreadDemo14 {
    volatile public static int flag = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (flag == 0) {
                //一直循环
            }
            System.out.println("循环结束，t1结束");
        });

        Thread t2 = new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            System.out.println("情输入任意一个整数");
            flag = scanner.nextInt();
        });

        t1.start();
        t2.start();
    }
}
